package per.hx.bs.web.yw.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import per.hx.bs.base.annotation.BsCLog;
import per.hx.bs.util.PageUtils;
import per.hx.bs.util.Query;
import per.hx.bs.vo.CountCheckUserVO;
import per.hx.bs.web.yw.service.YwCountService;

import java.util.List;
import java.util.Map;

/**
 * @author HuXing
 * @date 2018/4/28  15:30
 */
@Controller
@RequestMapping(value = "yw/count")
public class CountController {

    private final String prefix = "yw/count";

    private final
    YwCountService countService;

    @Autowired
    public CountController(YwCountService countService) {
        this.countService = countService;
    }

    @BsCLog("学院考核统计")
    @GetMapping(value = "/check")
    public String checkDept() {
        return prefix + "/checkDept";
    }

    @BsCLog("获取数据")
    @GetMapping(value = "/check/list")
    @ResponseBody
    public PageUtils listUser(@RequestParam Map<String, Object> map) {
        Query query = new Query(map);
        List<CountCheckUserVO> userVOS = countService.selectListUser(query);
        Integer count = countService.countListUser(map);
        return new PageUtils(userVOS, count);
    }

    @GetMapping(value = "/check/userDetail")
    public String userDetail(Long userId, String khDate, Model model) {
        model.addAttribute("userId", userId);
        model.addAttribute("khDate", khDate);
        return prefix + "/userDetail";
    }

    @BsCLog("指标统计")
    @GetMapping(value = "appraisal")
    public String appraisal() {
        return prefix + "/appraisal";
    }

    @BsCLog("获取数据")
    @GetMapping(value = "/appraisal/list")
    @ResponseBody
    public PageUtils appraisal(@RequestParam Map<String, Object> map) {
        List<Map<String, Object>> maps = countService.selectListAppraisal(map);
        System.out.println(maps);
        return new PageUtils(maps, maps.size());
    }

}
